package com.lagou.redisCluster;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPoolConfig;

import java.util.HashSet;
import java.util.Set;

/**
 * @author ascetic
 * @version 1.0
 * @ClassName RedisCluster
 * @Description TODO
 * @date 2021-02-16 17:01
 */
public class RedisCluster {

    public static void main(String[] args) {


        JedisPoolConfig config = new JedisPoolConfig();

        config.setMaxTotal(60);

        config.setMaxIdle(2);

        Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
        jedisClusterNode.add(new HostAndPort("172.17.0.2", 7001));
        jedisClusterNode.add(new HostAndPort("172.17.0.2", 7002));
        jedisClusterNode.add(new HostAndPort("172.17.0.2", 7003));
        jedisClusterNode.add(new HostAndPort("172.17.0.2", 7004));
        jedisClusterNode.add(new HostAndPort("172.17.0.2", 7005));
        jedisClusterNode.add(new HostAndPort("172.17.0.2", 7006));
        JedisCluster jcd = new JedisCluster(jedisClusterNode, config);
        jcd.set("name:001","zhangfei");
        String value = jcd.get("name:001");

        System.out.println("hello world");
    }
}